With the popularity of internet businesses, the amount of users is greatly increased. For a business, a single server has been far from providing services. Based on this, a large-scale server cluster has emerged. The server cluster refers to a group of servers which cooperate to complete one or a plurality if particular functions in the internet businesses. Configuration of all servers in the server cluster can be completed by a configuration system. A configuration center server of the configuration system reads configuration information from a database and issues the configuration information to the servers.
One solution for configuring server cluster in the related art includes: after receiving a configuration request from a server to be configured, a configuration center server obtains write lock from a local shared memory, obtains configuration information from a database of a configuration center and writes the configuration information in the shared memory, releases the write lock; obtains a read lock, reads the configuration information from the local shared memory, sends the read configuration information to the server to be configured, and releases the read lock.
The write lock and the read lock are stored in the shared memory of the configuration center server.
The write lock and the read lock are used for Linux inter-process communication. The read lock is also referred as shared lock, and the write lock is also referred as exclusive lock. The read lock and the write lock are often collectively referred to as read-write lock. When the read-write lock is locked in read mode, the read-write lock is locked in shared mode. When the read-write lock is locked in write mode, the read-write lock is locked in exclusive mode. That is, multiple processes or threads can simultaneously be in a read-write lock in read mode, while in a read-write lock in write mode, only one process is exclusive.
In the above process, the processing time between obtaining the write block and releasing the write lock as well as between obtaining the read lock and releasing the read lock is longer, i.e., it needs to take a longer time to write data and read data. Once an anomaly appears between obtaining the write block and releasing the write lock, an exit signal is received and the process will exit, and it will be too late to release the write lock stored in the shared memory; if the configuration center server subsequently receives a configuration request from a server to be configured, this will lead to a deadlock, the configuration information obtained from the database cannot be written into the shared memory, and then it is unable to read the configuration information from the shared memory and issue the configuration information to the sever to be configured. Similarly, once an anomaly appears between obtaining the read block and releasing the read lock, the process will exit, and it will be too late to release the read lock stored in the shared memory; if the configuration center server subsequently receives a configuration request from a server to be configured, there is no available read lock and this will lead to a deadlock, and the configuration information cannot be issued to the server to be configured.
Thus, the existing solution for configuring server cluster has following defects: when exiting abnormally, this will lead to a deadlock and the configuration information cannot be successfully issued to the server to be configured.